import React from "react";
import { Link } from "react-router-dom";
import DocumentTitle from "react-document-title";

import {userRegister} from '@/api/login'

import { Form, Input, Button} from "antd";

const register = () => {

    //  验证用户数据
    const onFinish = (values) => {
        userRegister(values).then((result) => {
            console.log(result);
            if(result.code === 200) {

            }
        }).catch((err) => {
            
        });
    };

    return (
        <DocumentTitle title={"用户注册"}>
            <div className="login_container">
                <div className="form">
                    <div className='logo'>
                        <h2>管理后台注册</h2>
                    </div>
                    <Form name="normal_login"
                        onFinish={onFinish}
                        initialValues={{
                            remember: true,
                        }}>
                        <Form.Item
                            name="phone"
                            id='phone'
                            rules={[{ required: true, message: '手机号是必填的' }]}
                        >
                            <Input placeholder="请输入手机号" className='borderR'

                            />
                        </Form.Item>
                        <Form.Item
                            name="userName"
                            id='userName'
                            rules={[{ required: true, message: '用户名是必填得' }]}
                        >
                            <Input placeholder="请输入用户名" className='borderR'

                            />
                        </Form.Item>
                        <Form.Item
                            name="password"
                            id='password'
                            rules={[{ required: true, message: '密码是必填得' }]}
                        >
                            <Input placeholder="请输入密码" className='borderR' />
                        </Form.Item>

                        <Form.Item
                        >
                            <Button type="primary" block={true} shape="round" htmlType="submit" >登陆</Button>
                        </Form.Item>
                    </Form>
                    <div className='foot'>
                        <Link to='/resiger'>
                            <span>已有账号，点我登陆</span>
                        </Link>
                    </div>
                </div>
            </div>
        </DocumentTitle>
    );
}

export default register